// import jsonp from 'common/js/jsonp'
// import { commonParams, options } from './config'

import { commonParams, baseUrl } from './config'

import axios from 'axios'

// 获得轮播图数据
export function getImages() {
    const url = baseUrl + 'api/getImages'
    const data = Object.assign({}, commonParams, {
        '-': 'recom2081473154824931',
        g_tk: 5381,
        hostUin: 0,
        format: 'json',
        platform: 'yqq.json',
        data: {
            focus: {
                module: 'QQMusic.MusichallServer',
                method: 'GetFocus',
                param: {}
            }
        }
    })

    return axios.get(url, {
        params: data
    }).then((res) => {
        return Promise.resolve(res.data)
    })
}

// 利用自起服务 欺骗qq音乐的haeder接口验证
export function getDiscList() {
    const url = baseUrl + 'api/getDiscList'
    const data = Object.assign({}, commonParams, {
        platform: 'yqq',
        hostUin: 0,
        sin: 0,
        ein: 29,
        sortId: 5,
        categoryId: 10000000,
        rnd: Math.random(),
        format: 'json'
    })

    return axios.get(url, {
            params: data
        }).then((res) => {
            return Promise.resolve(res.data)
        })
}

// 获得歌单的歌曲列表
export function getSongList(disstid) {
    const url = baseUrl + 'api/getCdInfo'

    // 配置数据
    const data = Object.assign({}, commonParams, {
        disstid,
        type: 1,
        json: 1,
        utf8: 1,
        onlysong: 0,
        hostUin: 0,
        platform: 'yqq'
    })

    return axios.get(url, {
        params: data
    }).then((res) => {
        return Promise.resolve(res.data)
    })
}
